package com.hyr.springcloud.user.controller;

import com.hyr.springcloud.dto.OrderDTO;
import com.hyr.springcloud.user.feign.OrderClient;
import com.hyr.springcloud.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private OrderClient orderClient;

    @RequestMapping("/getUser/{id}")
    public Object getUser(@PathVariable(name = "id") int id){
        OrderDTO order = orderClient.getOrder(1);
        Object user =  userInfoService.getUserInfo(id);
        Map<String,Object> result = new HashMap<>();
        result.put("user",user);
        result.put("order",order);
        return result;
    }
}
